package cn.tedu.controller;
/*
  访问方式：
  1.get方式
  2.restful方式
  3.Ajax访问
 */
import cn.tedu.pojo.Student;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@RequestMapping("stu")
public class StuCont {
    @RequestMapping("get")  /*前端触发点：http://localhost:8080/stu/get*/
    public  Student get(){
        Student s = new Student();//创建对象并设置值
//        s.setId(123);
//        s.setName("小希");
//        s.setAge(20);
//        s.setSex("女");
        /**链式编程*/
        s.setId(123).setName("哈哈").setAge(20).setSex("女");
        System.out.println(s);//Student{id=123, name='小希', age=20, sex='女'}
        return s;
    }
    /*前端触发点：http://localhost:8080/stu/obj*/
    @RequestMapping("obj")
    public  Student obj(Student s){
        //前后端打印显示
        System.out.println(s);
        return s; //Student{id=null, name='null', age=null, sex='null'}
    }
    /*前端触发点：http://localhost:8080/stu/restful/1234/达克/18/男*/
    @RequestMapping("restful/{a}/{b}/{c}/{d}")
    public  void  restful(
            @PathVariable Integer a,
            @PathVariable String b,
            @PathVariable Integer c,
            @PathVariable String d  ){
        System.out.println(a+b+c+d);//打印显示后台

    }

}
